package com.shwread.android.ui.page;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.shwread.android.qysw.activity.MainActivity;
import com.shwread.android.qysw.activity.VoteMainActivity;
import com.shwread.android.qysw.activity.task.QuestionnaireListActivity;
import com.shwread.android.qysw.activity.pay.PartyFeePayListActivity;
import com.shwread.android.qysw10000243.R;
import com.tgx.tina.android.ipc.framework.IUIPage;

import base.tina.core.task.infc.ITaskResult;

/**
 * 党员天地
 */
public class PartyMemberPage extends AbstractUIPage<MainActivity> implements View.OnClickListener {
    private static PartyMemberPage instance;
    private ImageView ivPersion;
    /**
     * 在线投票
     */
    private ImageView imgVoteOnLine;
    /**
     * 党费缴纳
     */
    private ImageView imgPartyFeePay;
    /**
     * 问卷调查
     */
    private ImageView imgQuestionnaireSurvey;

    public static PartyMemberPage getInstance(MainActivity t) {
        if (null == instance) {
            instance = new PartyMemberPage(t);
        } else {
            instance.setActivity(t);
        }
        return instance;
    }

    private PartyMemberPage(MainActivity t) {
        super(t);
    }

    @Override
    public <E extends Activity> View createView(E arg0, int arg1) {
        if (null != curMyView) {
            return curMyView;
        }
        curMyView = bActivity.getLayoutInflater().inflate(R.layout.page_party_member, null);
        initView();
        initData();
        initLayout();
        return curMyView;
    }

    private void initLayout() {
        ivPersion.setOnClickListener(this);
        imgVoteOnLine.setOnClickListener(this);
        imgPartyFeePay.setOnClickListener(this);
        imgQuestionnaireSurvey.setOnClickListener(this);
    }

    void initData() {
    }

    void initView() {
        //标题栏
        TextView tvTitle = (TextView) curMyView.findViewById(R.id.common_header_name);
        tvTitle.setText("党员天地");
        ivPersion = (ImageView) curMyView.findViewById(R.id.common_header_persion);
        ivPersion.setVisibility(View.VISIBLE);
        Button btnBack = (Button) curMyView.findViewById(R.id.common_header_back);
        btnBack.setVisibility(View.GONE);

        imgVoteOnLine = (ImageView) curMyView.findViewById(R.id.img_party_fee_pay);
        imgPartyFeePay = (ImageView) curMyView.findViewById(R.id.img_questionnaire_survey);
        imgQuestionnaireSurvey = (ImageView) curMyView.findViewById(R.id.img_vote_on_line);
    }

    @Override
    public int enter(IUIPage<?> arg0) {
        return 0;
    }

    @Override
    public int leave(IUIPage<?> arg0) {
        return 0;
    }

    @Override
    public void notifyView(int arg0, Bundle arg1) {
    }

    @Override
    public void setStatus(int arg0) {

    }

    @Override
    public View updateView(int arg0, ITaskResult arg1) {
        return null;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.common_header_persion://个人中心
                bActivity.goPersonalActivity();
                break;
            case R.id.img_party_fee_pay://党费缴纳
                intent2Acticity(PartyFeePayListActivity.class);
                break;
            case R.id.img_questionnaire_survey://问卷调查
                intent2Acticity(QuestionnaireListActivity.class);
                break;
            case R.id.img_vote_on_line://在线投票
                intent2Acticity(VoteMainActivity.class, "在线投票");
                break;
        }
    }
}
